<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $goods=array(
           'goods'=>array(
               0=>array(
                   'id'=>1,
                   'name'=>'西瓜子',
                   'weight'=>'200g',
                   'price'=>'0.01',
                   'image'=>'/image/c2.png'
               ),
               1=>array(
                   'id'=>2,
                   'name'=>'香菜',
                   'weight'=>'500g',
                   'price'=>'0.02',
                   'image'=>'/image/c4.png'
               ),
               2=>array(
                   'id'=>3,
                   'name'=>'薏米',
                   'weight'=>'375g',
                   'price'=>'0.03',
                   'image'=>'/image/s5.png'
               ),
               3=>array(
                   'id'=>4,
                   'name'=>'柚子',
                   'weight'=>'375g',
                   'price'=>'0.03',
                   'image'=>'/image/c2.png'
               ),
               4=>array(
                   'id'=>5,
                   'name'=>'猕猴桃',
                   'weight'=>'375g',
                   'price'=>'0.03',
                   'image'=>'/image/c4.png'
               ),
               5=>array(
                   'id'=>6,
                   'name'=>'竹笋',
                   'weight'=>'375g',
                   'price'=>'0.03',
                   'image'=>'/image/s5.png'
               ),
               6=>array(
                   'id'=>7,
                   'name'=>'薏米',
                   'weight'=>'375g',
                   'price'=>'0.03',
                   'image'=>'/image/s5.png'
               ),
               7=>array(
                   'id'=>8,
                   'name'=>'枸杞',
                   'weight'=>'375g',
                   'price'=>'0.03',
                   'image'=>'/image/c3.png'
               ),
           ),
           'imgUrls'=>array(
                 0=>  '/image/b1.jpg',
                 1=>  '/image/b2.jpg',
                 2=> '/image/b3.jpg'
           )

        );
        echo json_encode($goods);
    }
    
    
    
    public function cate(){
        
        $cIndex=trim(I('cIndex'));
        $idView=trim(I('idView'));
  
        switch ($idView){
            case 'guowei':
                $result=array(
                    'result'=>array(
                        0=>array(
                            'cate'=>'果味',
                            'id'=>'guowei',
                            'banner'=>'/image/c1.png',
                            'detail'=>array(
                                0=>array(
                                    'name'=>'冰糖雪梨',
                                    'thumb'=>'/image/c2.png'
                                ),
                                1=>array(
                                    'name'=>'红枣',
                                    'thumb'=>'/image/c4.png'
                                ),
                                2=>array(
                                    'name'=>'奇异果 ',
                                    'thumb'=>'/image/c3.png'
                                ),
                            ),
                        ),
                    ),
                );
              echo json_encode($result);   
            break;
            case 'shucai':
                $result=array(
                    'result'=>array(
                        0=>array(
                            'cate'=>'蔬菜',
                            'id'=>'shucai',
                            'banner'=>'/image/c1.png',
                            'detail'=>array(
                                0=>array(
                                    'name'=>'胡萝卜',
                                    'thumb'=>'/image/c3.png'
                                ),
                                1=>array(
                                    'name'=>'白萝卜 ',
                                    'thumb'=>'/image/c2.png'
                                ),
                                2=>array(
                                    'name'=>'奇异果 ',
                                    'thumb'=>'/image/c4.png'
                                ),
                            ),
                        ),
                    ),
                );
                echo json_encode($result);
            break;
        }
        
     
        
    }
    
    

    
    public function detail(){
        
        $gid =trim(I('gid'));
        
        switch ($gid){
         
            case '1':
                $result = array(
                    'detail'=>array(
                        'id'=>1,
                        'image'=>'/image/c2.png',
                        'title' =>'西瓜子',
                        'price'=>'0.01',
                        'weight'=>'200g',
                        'stock'=> '有货',
                        'detail'=> '你看着图片是梨,实际上是西瓜子。',
                        'parameter'=> '212g/个',
                        'service'=> '不支持退货'
                    ),
            
                );
                echo json_encode($result);
            break;     
            case '2':
                $result = array(
                'detail'=>array(
                'id'=>2,
                'image'=>'/image/c4.png',
                'title' =>'猕猴桃',
                'price'=>'0.01',
                'weight'=>'200g',
                'stock'=> '有货',
                'detail'=> '你看着图片是梨,实际上是西瓜。',
                'parameter'=> '212g/个',
                'service'=> '不支持退货'
                    ),
            
                );
                echo json_encode($result);
                break;
        }

        
    }
    
    public function order(){
        $gid=trim(I('id'));
        $num =trim(I('num'));

        $result=array(
            'carts'=>array(
                0=>array(
                    'id'=>1,
                    'title'=>'西瓜子',
                    'image'=>'/image/s5.png',
                    'num'=>4,
                    'price'=>0.01,
                    'selected'=>true
                ),
                1=>array(
                    'id'=>2,
                    'title'=>'新鲜芹菜',
                    'image'=>'/image/s2.png',
                    'num'=>4,
                    'price'=>0.41,
                    'selected'=>true
                ),
            ),
        );
        
       echo json_encode($result);
        
        
    }

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}